function CharacterCreation(game){
	this.game = game;
	this.step = 1;
	
	this.name = "";
	
	this.game.lastK = -1;
}

CharacterCreation.prototype.nameKeyBindings = function(){
	if (this.game.lastK != -1){
		if ((this.game.lastK >= 65 && this.game.lastK <= 90) || (this.game.lastK >= 97 && this.game.lastK <= 122)){
			this.name += String.fromCharCode(this.game.lastK);
		}else if (this.game.lastK == 32){
			this.name += " ";
		}else if (this.game.lastK == 8){
			this.name = this.name.substring(0, this.name.length-1);
		}
		
		this.game.lastK = -1;
	}
};

CharacterCreation.prototype.drawStep1 = function(){
	var ctx = this.game.eng.ctx;
	
	ctx.textAlign = "left";
	ctx.fillText("Name: " + this.name, 16, 60);
	ctx.fillText("Insert your name (12 Characters max)", 16, 80);
	ctx.fillText("Press Enter when you are ready", 16, 100);
	
	this.nameKeyBindings();
	if (this.game.keys[13] == 1){
		this.step += 1;
		this.game.keys[13] = 2;
	}
};

CharacterCreation.prototype.drawStep2 = function(){
	var ctx = this.game.eng.ctx;
	
	ctx.textAlign = "left";
	ctx.fillText("Name: " + this.name, 16, 60);
};

CharacterCreation.prototype.startGame = function(){
	this.game.scene = null;
	this.game.map = new Map(this.game);
	this.game.maps = [this.game.map];
};

CharacterCreation.prototype.loop = function(){
	var ctx = this.game.eng.ctx;
	
	ctx.fillStyle = "black";
	ctx.fillRect(0,0,ctx.width,ctx.height);
	
	ctx.fillStyle = "white";
	ctx.textAlign = "center";
	ctx.fillText("Character Creation", ctx.width / 2, 20);
	
	switch (this.step){
		case 1: this.drawStep1(); break;
		case 2: this.drawStep2(); break;
	}
};